import 'package:flutter/material.dart';
import 'package:flutter_app02/Tabs.dart';
import 'package:flutter_app02/pages/infos/Search.dart';
import 'package:flutter_app02/pages/infos/Button.dart';
import 'package:flutter_app02/pages/infos/Field.dart';
import 'package:flutter_app02/pages/infos/CheckBox.dart';
import 'package:flutter_app02/pages/infos/Radio.dart';
import 'package:flutter_app02/pages/infos/StudentDJ.dart';
import 'package:flutter_app02/pages/infos/DatePicker.dart';
import 'package:flutter_app02/pages/infos/DateTimePicker.dart';
import 'package:flutter_app02/pages/infos/Swiper1.dart';
import 'package:flutter_app02/pages/infos/Dialog1.dart';
import 'package:flutter_app02/pages/infos/data.dart';


final Map<String,Function> routes={
  '/':(context,{arguments})=>Tabs(),
  '/search':(context,{arguments})=>Search(),
  '/button':(context,{arguments})=>ButtonPage(),
  '/field':(context,{arguments})=>FieldPage(),
  '/checkbox':(context,{arguments})=>CheckBoxPage(),
  '/radio':(context,{arguments})=>RadioPage(),
  '/student':(context,{arguments})=>StudentDJ(),
  '/date':(context)=>DatePicker(),
  '/datetimepicker':(context)=>DateTimePickerPage(),
  '/swiper1':(context)=>SwiperPage1(),
  '/dialog1':(context)=>DialogPage(),
  '/data1':(context)=>DataPage(),
};

//固定写法,要记得main中调用
var onGenerateRoute = (RouteSettings settings) {
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) => pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route = MaterialPageRoute(
          builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
